﻿using System;

namespace Microsoft.Coding4Fun.TweetCraft.Twitter
{
    /// <summary>
    /// Implements error reporting for Twitter-based services.
    /// </summary>
    public abstract class TwitterService : IReportsError
    {
        /// <summary>
        /// Raised when an error occurs.
        /// </summary>
        public event EventHandler<ErrorEventArgs> Error;

        /// <summary>
        /// Reports an error.
        /// </summary>
        /// <param name="exception">The exception that contains the error details.</param>
        protected void OnError(Exception exception)
        {
            if (Error != null)
            {
                Error(this, new ErrorEventArgs(exception));
            }
        }
    }
}
